﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _76父类引用指向子类对象
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            Dog d = new Dog();
            Cat c = new Cat();
            Animal animal = d;
            Animal animal1 = c;

            Animal[] array = { d, c, new Cat() };

            Test(d);
            Test(d); ;
            Test(new Pig());
        }

        private static void Test(Animal animal)
        {
        }
    }

    internal class Animal
    {
    }
    internal class Dog : Animal
    {
    }
    internal class Cat : Animal
    {
    }

    internal class Pig : Animal
    {
    }
}